<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../../include/admincontent_exam.jsp" %>
<link rel="stylesheet" href="../../resources/js/plugins/layui/css/layui.css" />
<div id="planpanel" class="condition_cont">
    <form id="thisform1" method="post" action="/Do/BS/AssignmentAction?pid=${pid}&fid=${fid}&deptcode=${deptcode}">
        <table class="treeTable searchform">
            <input type="hidden" name="pid" value="${pid}"/>
            <input type="hidden" name="fid" value="${fid}"/>
            <input type="hidden" name="deptcode" value="${deptcode}"/>
            <input type="hidden" name="room" id="room" value=""/>
            <thead>
            <tr>
                <td>考试日期:</td>
                <td width="220">
                    <div><input type="text" id="bsdate" name="bsdate" class="select"   datatype="*" nullmsg="请填写考试时间!" />

                    </div>

                </td>
                <td style="text-align: right">应聘岗位:</td>
                <td style="text-align:left">
                    <div>
                        <select name="jname" id="jname">
                            <option value="">请选择</option>
                            <c:forEach var="projectinfojobs" items="${jobs}" varStatus="item" >
                                <c:choose>
                                    <c:when test="${projectinfojobs!=null}">
                                        <option value="${projectinfojobs.jobname}">${projectinfojobs.jobname}</option>
                                    </c:when>
                                </c:choose>
                            </c:forEach>
                        </select>
                    </div>
                </td>
            </tr>
            <tr>
                <td>考试时段:</td>
                <td width="220">
                    <div><input type="text" id="bstimes" name="bstimes" class="select" datatype="*" nullmsg="请填写考试时段!" />
                    </div>
                </td>
                <td style="text-align:right">考场地址:</td>
                <td style="text-align:left">
                    <div><select name="address" id="bsAddress" datatype="*" nullmsg="请选择考场"></select></div>
                </td>
            </tr>
            <tr>
                <td width="90">考场列表:</td>
                <td colspan="3">

                    <div id="bsRoom"></div>
                </td>

            </tr>
            <tr>
                <td>备注:</td>
                <td colspan="2">
                    <div><input type="text" name="remark"/></div>
                </td>
                <td style="text-align:left">用于准考证备注栏</td>
            </tr>
            <tr>
                <td width="80">确认截止时间:</td>
                <td colspan="2">
                   <%-- <div><input type="text" id="endtime" name="endtime" class="select" onFocus="blur()" onclick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})"/></div>--%>
                    <div><input type="text" id="endtime" name="endtime" class="select" datatype="*"/></div>
                </td>
                <td style="text-align:left">不设定默认为笔试前2天!</td>
                <td></td>

            </tr>
            <tr>
                <td>注意事项:</td>
                <td colspan="2">
                    <div id="div_bszysx">
                        <textarea name="bszysx" id="bszysx" style="width:99%;height:150px;" > ${bszysx}</textarea>
                    </div>
                </td>
                <td style="text-align:left">笔试注意事项,如无注意事项<a href="javascript:clearZysx()">清除</a>内容即可</td>
            </tr>
            <tr>
                <td></td>
                <td colspan="3">
                    <button type="submit" class="op">一键分配</button>
                </td>
            </tr>
            </thead>
        </table>
        <div id="bsusers"></div>
    </form>
</div>
<%--<script src="../../resources/js/plugins/layui/layui.all.js" type="text/javascript"></script>--%>
<script charset="utf-8" src="/resources/js/plugins/layui/layui.all.js"></script>
<script charset="utf-8" src="/resources/js/plugins/kindeditor-4.1.10/kindeditor-min.js"></script>
<script charset="utf-8" src="/resources/js/plugins/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script>

    var laydate;
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('#bszysx', {
            resizeType: 1,
            items: ['removeformat'],
            afterBlur: function () {
                this.sync();
            }
        });
    });

    function clearZysx() {
        editor.html('');
    }

    layui.use('laydate', function () {
        laydate = layui.laydate;

    });
    laydate.render({
        elem: '#bsdate'
        //,type: 'date' //默认，可不填
        , value: new Date()
        , theme: 'grid'
    });
    laydate.render({
        elem: '#bstimes'
        , type: 'time'
        , range: '~' //或 range: '~' 来自定义分割字符
        , value: '09:00:00 ~ 00:00:00'
        , theme: 'grid'
    });
    laydate.render({
        elem: '#endtime'  ,
        type: 'datetime',
        format: 'yyyy-MM-dd HH:mm'
        , theme: 'grid'
    });

    $(document).ready(function () {
        $('#searchbtn').click(function () {
            $('#bsusers').html('');
            $('#msgusers').html('');
            getList();
        });
        $('#bsdate').focus();
        $('#bstimes').focus(function () {
            var bsdate=$('#bsdate').val();
            if(!!!bsdate){
                layer.msg('请先选择考试日期!',{icon:7,time:2000});
            }
        });
        $('#bstimes').click(function () {
            var bsdate=$('#bsdate').val();
            var bstime=$('#bstimes').val();
            if(!!!bsdate){
                layer.msg('请先选择考试日期!',{icon:7,time:2000});
                $('#bsdate').focus();
            }
            if (!!!bstime){
                $('#bstimes').focus();
            }
            $.ajax({
                url:"/Do/BS/getAddress",
                type:"POST",
                dataType:"json",
                success:function(data){
                 //   console.log($(data));
                    $('#bsAddress').empty();
                    $(data).each(function (index,address) {
                        $('#bsAddress').append('<option value="'+address+'">'+address+'</option>');
                    });
                   // console.log(data);
                }
            });

        });
        $('#bsAddress').click(function () {
            var bsdate=$('#bsdate').val();
            var bstimes=$('#bstimes').val();
            var bsaddress=$('#bsAddress').val();
            if(!!!bsdate){
                layer.msg('请先选择考试日期!',{icon:7,time:2000});
                $('#bsdate').focus();
            }
            if(!!!bstimes||bstimes=='09:00:00 ~ 00:00:00'){
                layer.msg('请先选择考试时段!',{icon:7,time:2000});
                $('#bstimes').focus();
            }
            if (!!!bsaddress) {
                $('#bsAddress').focus();
            }
            $.ajax({
                url:"/Do/BS/getCanUseRoomByAddress",
                type:"POST",
                data:{date: bsdate,times:bstimes,type:0,address:bsaddress},
                dataType:"json",
                success:function(data){
                    $('#bsRoom').empty();
                    $(data).each(function (index,room) {
                        //$('#bsRoom').append('<option value="'+room.id+'">'+room.name+'['+room.kbrs+']'+'</option>');
                        $('#bsRoom').append('<input type="checkbox" value="'+room.id+'">'+room.name+'['+room.kbrs+']'+'</input>');
                    });
                    $('#bsRoom input[type=checkbox]').click(function () {
                        var rooms=$('#bsRoom input[type=checkbox]:checked');
                        var r="";
                        if (!!rooms){
                            $('#room').val(r);
                            $(rooms).each(function (i,v) {
                                 r+=$(v).val()+",";
                            });
                        }
                        $('#room').val(r);
                      //  console.log($('#room').val());
                    });
                }
            });

        });
       /* $('#bsAddress').click(function () {
            var bsdate=$('#bsdate').val();
            var bstimes=$('#bstimes').val();
            if(!!!bsdate){
                layer.msg('请先选择考试日期!',{icon:7,time:2000});
                $('#bsdate').focus();
            }
            if(!!!bstimes||bstimes=='09:00:00 ~ 00:00:00'){
                layer.msg('请先选择考试时段!',{icon:7,time:2000});
                $('#bstimes').focus();
            }

        });*/


        var form;
        layui.use('form', function () {
            form = layui.form;
            //各种基于事件的操作，下面会有进一步介绍
            form.render();
        });


        /* $('#btn_cancel').click(function () {
             layer.closeAll();
         })*/
        //
        // $("#flowItem").append(
        //     "<input type=\"checkbox\" name=\"KEY.QYDATE\" title=\"签约时间\" value=\"签约时间\">" +
        //     "<input type=\"checkbox\" name=\"KEY.QYSTATE\" title=\"签约结果\" value=\"签约结果\">" +
        //     "<input type=\"checkbox\" name=\"KEY.QYREMARK\" title=\"签约备注\" value=\"签约备注\">")
        form.render();
    })
</script>